import {Http,RequestOptions} from  "@angular/http";

import {LoggerService} from "./logger.service";
import {LoginService} from "./login.service";
import {OldloggerService} from "./oldlogger.service";
import {ValuesService} from "./values.service";
import {AuthorService} from "./author.service";
import {UserService,UserServiceProvider} from './user.service';
import {DataService} from "./data.service";

import {HttpInterceptorService} from "./http-interceptor.service";
import {HttpInterceptorBackendService,httpFactory} from "./http-interceptor-backend.service"


const providers=[
    LoggerService,
    //login 服务中使用了logger 服务如下配置
    [LoggerService,{provide:LoginService,useClass:LoginService}],
    //旧的服务不用了指向了logger，useExisting 表示使用同一个logger 不再创建实例
    {provide:OldloggerService,useExisting:LoggerService},
    //useClass 配置使用Old 时还会创建一个logger 实例
    //{provide:OldloggerService,useClass:LoggerService}
    //值类型服务
    //{provide:ValuesService,useValue:ValuesService},
    AuthorService,
    //useFactory 表示此提供商是 工厂方法，实现是UserServiceProvider 函数
    //deps 是提供商的令牌数组（就是provide值），会把这些服务注入到工厂方法中，以参数引入
    // {
    //     provide:UserService,useFactory:UserServiceProvider,
    //     deps:[LoggerService,AuthorService]
    // },
    HttpInterceptorService,HttpInterceptorBackendService,
    {provide:Http,useFactory:httpFactory,deps:[HttpInterceptorBackendService,RequestOptions]},
    DataService
];
export {providers};

